<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-layout/jquery.layout-latest.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet"/>

<body class="gray-bg">
<div class="ui-layout-west">
	<div class="main-content">
		<div class="box box-main">
			<div class="box-header">
				<div class="box-title">
					<i class="fa icon-grid"></i> 组织机构
				</div>
				<div class="box-tools pull-right">
					<a type="button" class="btn btn-box-tool menuItem" href="#" onclick="dept()" title="管理部门"><i class="fa fa-edit"></i></a>
					<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
					<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
					<button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新部门"><i class="fa fa-refresh"></i></button>
				</div>
			</div>
			<div class="ui-layout-content">
				<div id="tree" class="ztree"></div>
			</div>
		</div>
	</div>
</div>
<div class="container-div ui-layout-center">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="xyzlb-form">
				<input type="hidden" id="deptId" name="deptId">
				<input type="hidden" id="parentId" name="parentId">
				<div class="select-list">
					<ul>
						<li>
							姓    名：<input type="text" name="studentName"/>
						</li>
						<li>
							手机号码：<input type="text" name="studentTelephone"/>
						</li>
						<li>
							身份证号码：<input type="text" name="identity"/>
						</li>

						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>
		<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
			<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="project:xyzlb:add">
				<i class="fa fa-plus"></i> 添加
			</a>
			<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="project:xyzlb:edit">
				<i class="fa fa-edit"></i> 修改
			</a>
			<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="project:xyzlb:remove">
				<i class="fa fa-remove"></i> 删除
			</a>
		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>

	</div>
</div>

<div th:include="include :: footer"></div>
<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('project:xyzlb:edit')}]];
    var removeFlag = [[${@permission.hasPermi('project:xyzlb:remove')}]];
    var datas = [[${@dict.getType('sys_user_sex')}]];
    var datas1 = [[${@dict.getType('zl_xyzlb_huny')}]];
    var datas2 = [[${@dict.getType('zl_hyzlb_xiaoh')}]];
    var datas3= [[${@dict.getType('zl_song_leibie')}]];
    var dates6;
    var prefix = ctx + "project/xyzlb";

    $(function() {
        $('body').layout({ west__size: 185 });
        queryDeptTree();
        queryXyzlbList();
    });

    function queryXyzlbList() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            modalName: "学员资料",
            queryParams: function() {
                return {
                    // 传递参数查询参数
                    deptId: 100
                };
            },
            columns: [{
                checkbox: true
            },
                {
                    field : 'studentId',
                    title : '学员id'
                },
                {
                    field : 'deptId',
                    title : '机构ID'
                },
                {
                    field : 'deptName',
                    title : '机构名称'
                },
                {
                    field : 'studentNumber',
                    title : '学员编号'
                },
                {
                    field : 'studentName',
                    title : '姓 名'
                },
                {
                    field : 'sex',
                    title : '性别',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field : 'nation',
                    title : '民族'
                },
                {
                    field : 'studentTelephone',
                    title : '手机号码'
                },
                {
                    field: 'birthday',
                    title: '出生日期',
                    formatter: function(value, row, index) {
						var t=value;
						console.log(t)
						var a=t.substr(0,10);
						console.log(a)
						return a;
                    }
                },
                {
                    field : 'birthday',
                    title : '年龄',
                    formatter: function(value, row, index) {
                        var date = new Date();
                        var birthday1 = value;
                        console.log(birthday1)
                        var startDate = new Date(birthday1);
                        var newDate = date.getTime() - startDate.getTime();
                        // 向下取整  例如 10岁 20天 会计算成 10岁
                        // 如果要向上取整 计算成11岁，把floor替换成 ceil
                        var age1 = Math.floor(newDate / 1000 / 60 / 60 / 24 / 365);
                        return age1;
                    }
                },

//                {
//                    field : 'age',
//                    title : '年龄'
//                },
//
                {
                    field : 'marriage',
                    title : '婚姻状况',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas1, value);
                    }
                },
                {
                    field : 'child',
                    title : '是否有小孩',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(datas2, value);
                    }
                },
                {
                    field : 'studentAddress',
                    title : '住址'
                },

                {
                    field : 'identity',
                    title : '身份证号码'
                },
                {
                    field : 'identityz',
                    title : '身份证图片正面',
					formatter:function (value, row, index) {
                        var img_path = value == '' ? '' : '/profile/card/'+ value;
                    	return "<img alt='image' class='m-t-xs img-responsive' src='"+img_path+"'>";
                    }
                },
                {
                    field : 'identityf',
                    title : '身份证图片反面',
                    formatter:function (value, row, index) {
                        var img_path = value == '' ? '' : '/profile/card/'+ value;
                        return "<img alt='image' class='m-t-xs img-responsive' src='"+img_path+"'>";
                    }
                },
                {
                    field : 'courseType',
                    title : '课程类型',
                    formatter: function(value, row, index) {
                        if("level"==value){
                            dates6 = [[${@dict.getType('zl_subject_level')}]];
                        } else {
                            dates6 = [[${@dict.getType('zl_subject_year')}]];
                        }
                        return $.table.selectDictLabel(datas3, value);
                    }
                },
                {
                    field : 'chargeLevel',
                    title : '收费等级',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(dates6, value);
                    }
                },
                {
                    field : 'expirationDate',
                    title : '失效日期'
                },
                {
                    field : 'paymentDate',
                    title : '缴费日期',
					formatter:function (value,row,index) {
						var a=value;
						var b=a.substr(0,10);
						return b;
                    }
                },
                {
                    field : 'receptionist',
                    title : '接待教师'
                },
                

                {
                    field : 'remark',
                    title : '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.studentId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.studentId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    }
    function queryDeptTree()
    {
        var url = ctx + "system/dept/rolesDeptTreeData";
        var options = {
            url: url,
            expandLevel: 2,
            onClick : zOnClick
        };
        $.tree.init(options);
        function zOnClick(event, treeId, treeNode) {
            $("#deptId").val(treeNode.id);
            $("#parentId").val(treeNode.pId);
            $.table.search();
        }
    }

    $('#btnExpand').click(function() {
        $._tree.expandAll(true);
        $(this).hide();
        $('#btnCollapse').show();
    });

    $('#btnCollapse').click(function() {
        $._tree.expandAll(false);
        $(this).hide();
        $('#btnExpand').show();
    });

    $('#btnRefresh').click(function() {
        queryDeptTree();
    });
</script>
</body>
</html>